/**
 * @(#)TextAlign.java
 *
 *
 * @author
 * @version 1.00 2011/12/14
 */
import java.awt.*;

public class TextAlign implements LayoutManager{
	private int margen=5;
    private int interlineado=5;

    public TextAlign(){
    }

    public void addLayoutComponent(String name, Component comp){

    }

    public void layoutContainer(Container parent){
    	int y=0;

    	for(int k=0; k<parent.getComponentCount(); k++){
    		Component c=parent.getComponent(k);

    		Dimension p=c.getPreferredSize();
    		c.setSize(p);
    		c.setLocation(margen, y);
    		y+=p.getHeight();
    	}
    }

    public Dimension preferredLayoutSize(Container parent){
    	int w=0;
    	int h=0;

    	for(int k=0; k<parent.getComponentCount(); k++){
    		Component c=parent.getComponent(k);

    		Dimension p=c.getPreferredSize();
    		w=(int)Math.max(w, p.getWidth());

    		h+=p.getHeight()+interlineado;
    	}
    	return new Dimension(w+margen*2, h);
    }

    public Dimension minimumLayoutSize(Container parent){
    	return preferredLayoutSize(parent);
    }

    public void removeLayoutComponent(Component comp){
    }
}